take derivative with trigonometric functions